]>
wirehaze git hosting - BOS.git/blob - kernel/testkernels etc/kernel.asm
1 ;------------------------------------------------------------;
3 ;------------------------------------------------------------;
5 ; by: Christoffer Bubach, 2003-2005 ;
6 ; http://bos.asmhackers.net/ asmhacker@gmail.com ;
8 ;------------------------------------------------------------;
10 ; 16-bit mem map (seg:off)
11 ; 0x0000:0x0000 -> 0x0000:0x0500 BIOS stuff
12 ; 0x0000:0x0500 -> 0x0000:0x2100 root
13 ; 0x0000:0x2100 -> 0x0000:0x3300 fat
14 ; 0x0000:0x3300 -> 0x0000:0x6c00 14,25kb free space
15 ; 0x0000:0x6c00 -> 0x0000:0x7c00 IDT and GDT (256 desc. eatch)
16 ; 0x0000:0x7c00 -> 0x0000:0x7e00 bootsector
17 ; 0x0000:0x7e00 <- 0x0000:0xffff ~32,5kb stack for boot
18 ; 0x1000:0x0000 -> 0x9000:0xffff 576kb free space
19 ; 0xa000:0x0000 -> ............. VGA mem etc.
25 include 'realmode/a20.inc'
26 include 'realmode/variables.inc'
27 ;----------------------------------------------------;
28 ; show a message and wait for a key before reboot ;
29 ;----------------------------------------------------;
43 first16 db 'Now in 16 bit mode.'
46 ;------------------------------------------;
47 ; starting point of second stage code ;
48 ;------------------------------------------;
52 mov ds, ax ; registers.
55 mov sp, 0xFFFF ; Stack..
59 ;----------------------;
61 ;----------------------;
82 ;------------------------;
84 ;------------------------;
89 ; mov [BaseAddOn], ebx
92 ; mov [gdt.BOS_code + 2], ax
93 ; mov [gdt.BOS_data + 2], ax
94 ; mov [gdt.BOS_16code + 2], ax
95 ; mov [gdt.BOS_16data + 2], ax
99 ; mov [gdt.BOS_code + 4], al
100 ; mov [gdt.BOS_data + 4], al
101 ; mov [gdt.BOS_16code + 4], al
102 ; mov [gdt.BOS_16data + 4], al
104 ; mov [gdt.BOS_code + 7], ah
105 ; mov [gdt.BOS_data + 7], ah
106 ; mov [gdt.BOS_16code + 7], ah
107 ; mov [gdt.BOS_16data + 7], ah
111 ; mov [gdtr + 2], ebx
112 ; add ebx, idt_start - gdt
113 ; mov [idtr + 2], ebx
116 mov bx,ds ; BX=segment
117 shl ebx,4 ; BX="linear" address of segment base
119 mov [sys_code_1
+ 2],ax ; set base address of 32-bit segments
120 mov [sys_data_1
+ 2],ax
121 mov [Real_code_1
+ 2],ax ; set base address of 16-bit segments
122 mov [Real_data_1
+ 2],ax
124 mov [sys_code_1
+ 4],al
125 mov [sys_data_1
+ 4],al
126 mov [Real_code_1
+ 4],al
127 mov [Real_data_1
+ 4],al
129 mov [sys_code_1
+ 7],ah
130 mov [sys_data_1
+ 7],ah
131 mov [Real_code_1
+ 7],ah
132 mov [Real_data_1
+ 7],ah
134 add ebx,gdt
; EBX=linear address of gdt
137 cli ; Disable interrupts,
140 lgdt [gdtr
] ; Load the GDT descriptor
142 mov eax, cr0 ; Copy the contents of CR0 into EAX
143 or eax, 1 ; Set bit 0
144 mov cr0, eax ; Copy the contents of EAX into CR0
146 ;jmp 10h:clear_pipe ; Jump to code segment, offset clear_pipe
148 ; cli ; set protected mode (32-bit)
156 ;----------------------------------------;
157 ; start of 32-bit area. ;
158 ; flush segments and jump to kernel ;
159 ;----------------------------------------;
162 mov eax, 0x10 ; refresh all segment registers
170 mov byte [ds:0B8502h], 'P'
171 mov byte [ds:0B8503h], 0x07 ; Assign a color code
177 ;--------------------------------;
178 ; global descriptor table (gdt) ;
179 ;--------------------------------;
181 .null: dw 0x0000, 0x0000, 0x0000, 0x0000
182 .codesel: dw 0xFFFF, 0x0000, 0x9800, 0x00CF
183 .datasel: dw 0xFFFF, 0x0000, 0x9200, 0x00CF
187 .size: dw gdt_end
- gdt
- 1
188 .address dd gdt
;+ 0x10000 ; 0x10000 is where we are in mem